home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6116 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  51 lines

  1. Path: thor.tu.hac.com!collins
  2. From: collins@thor.tu.hac.com (Ron Collins)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Do you have ever pass structures?
  5. Date: 22 Feb 1996 18:55:56 GMT
  6. Organization: Advanced Depot Systems
  7. Message-ID: <4gie7s$jim@hacgate2.hac.com>
  8. References: <4ge8mi$qjm@srvr1.engin.umich.edu> <312BE9C9.67A2284E@eden.com>
  9. NNTP-Posting-Host: thor.tu.hac.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Shane Sadler (nexus@eden.com) wrote:
  13.  
  14. : As you know passing an entire structure to a function pushes that
  15. : structure onto the stack. By passing pointers, you avoid that sort of
  16. : overhead and your code is more efficient. When I'm writing what Mr.
  17. : Collins would call "disposable programs," I might just declare my
  18.   ^^^^^^^
  19.  
  20. Sounds like an intelligent, rational, good-looking chap.
  21.  
  22. : structures globally just out of laziness and expediency, but I can't
  23. : think of a case in which I would pass the whole structure. So my answer
  24. : would be "no". Of course, someone else may have experience with passing
  25. : very small structures (one or two elements). There might be some
  26. : advantage in this, but a "REAL" advantage? I doubt it. Depends on what
  27. : you mean by "REAL," I guess...
  28.  
  29. : -- Shane
  30.  
  31.  
  32. About the only use I can come up with for passing a large structure on the
  33. stack would be to interface to a routine written in another language.
  34. Exactly what that language would be, I haven't a clue.  Outside of this,
  35. the pass-by-value mechanism for a large structure seems like one of those
  36. interesting little tidbits that is nice to know about, but rarely ever
  37. used.
  38.  
  39. Anyone have any examples of using this, where it actually saved time or
  40. effort over passing a pointer?
  41.  
  42.  
  43.                         -- Collins --
  44.                         
  45. -----
  46. The views expressed here are mine alone.
  47.  
  48. Ron Collins/Hughes Aircraft Company/M20,P20/Tucson Az 85706
  49. rcollins@thor.tu.hac.com    collins@seagull.rtd.com
  50. ยก----
  51.